package com.kaikai.edu.controller.front;

import com.kaikai.commonutils.R;
import com.kaikai.edu.entity.EduCourse;
import com.kaikai.edu.entity.EduTeacher;
import com.kaikai.edu.service.EduCourseService;
import com.kaikai.edu.service.EduTeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("eduservice/index")
@CrossOrigin
public class IndexFrontController {
    @Autowired
    private EduCourseService courseService;
    @Autowired
    private EduTeacherService teacherService;
    //获取8条课程信息和4条讲师信息
    @GetMapping("getIndex")
    public R index(){
        /**
         * 获取首页的8个课程和4个名师
         */
        List<EduCourse> courses = courseService.list8_courses();
        List<EduTeacher> teachers = teacherService.list4_teachers();
        return R.ok().data("courses",courses).data("teachers",teachers);

    }
}
